# # vector
# a <-c(1,2,5,3,6,-2,4)
# b <-c("one","two","three")
# c <-c(TRUE,TRUE,TRUE,FALSE,TRUE,FALSE)
# print(a)
# print(b)
# print(c)

# # matrix
# y <-matrix(1:20,nrow=5,ncol=4)
# print(y)
# cells <-c(1,26,24,68)
# rnames <-c("R1","R2")
# cnames <-c("C1","C2")
# #默认情况下按行填充
# mymatrix <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
# print(mymatrix)
# print(y[3,])
# print(y[,2])
# print(y[3,2])
# print(y[1,c(1,4)])
# print(y[2,2:3])
# print(mymatrix["R1","C2"])

# #array
# dim1 <- c("A1","A2")
# dim2 <- c("B1","B2","B3")
# dim3 <- c("C1","C2","C3","C4")
counts <- table(Arthritis$Improved,Arthritis$Treatment)
par(pin=c(3,2),mai=c(0.5,1,0.5,0),mfrow=c(1,2))
# layout(matrix(c(1,1,2,2),2,2,byrow=FALSE))
barplot(counts,main="stacked bar plot",xlab="improvement",ylab="freqency",col=c("red","yellow","green"),legend=rownames(counts))
barplot(counts,
        main='horizontal bar plot',
        xlab="freqency",ylab="imporvement",
        col=c("red","yellow","green"),
        legend=rownames(counts),
        beside=TRUE
       )